﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmFichaCliente.aspx.cs" Inherits="sistema_Despacho_frmFichaCliente" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <link href="../../kendoui.web/content/shared/styles/examples-offline.css" rel="stylesheet"/>
    <link href="../../kendoui.web/styles/kendo.common.min.css" rel="stylesheet"/>
    <link href="../../kendoui.web/styles/kendo.default.min.css" rel="stylesheet"/>

    <script src="../../kendoui.web/js/jquery.min.js" type="text/javascript"></script>
    <script src="../../kendoui.web/js/kendo.web.min.js" type="text/javascript"></script>
    <script src="../../kendoui.web/content/shared/js/console.js" type="text/javascript"></script>
 <%--   <style type="text/css">
        .style4
        {
            width: 19%;
        }
        .style10
        {
            width: 97%;
        }
        .style11
        {
            width: 15%;
        }
        .style12
        {
            width: 18%;
        }
        .style13
        {
            width: 17%;
        }
        .style14
        {
            width: 32%;
        }
        #DatoPrima
        {
            width: 99%;
        }
        .style15
        {
            width: 14%;
        }
        .style16
        {
            width: 21%;
        }
    </style>--%>
</head>
<body>
    <div id="frmContainer" class="k-content">
    <table border="0" width="100%">
    <tr>
        <td colspan="8" align="center"><h2>ADMINISTRAR FICHA CLIENTE</h2></td>
    </tr>
    <tr>
        <td colspan="8" align="center">&nbsp;</td>
    </tr>
    <tr>
        <td>Cliente:</td>
        <td><input id="txtCliente" style="width: 200px" class="k-textbox" /></td>       
        <td colspan="2" align="center"><button class="k-button" id="btnBuscar" style="width:160px;"><span class="k-icon k-i-search"></span>&nbsp;Ver Ficha</button></td>
        <td colspan="2" align="center"><button class="k-button" id="btnSalir" style="width:160px;"><span class="k-icon k-i-close"></span>&nbsp;Salir</button></td>
        
    </tr>
    <tr>
        <td colspan="8" align="center" class="style10"><hr/></td>
    </tr>
        
     <tr>
        <td colspan="4" align="left" class="style10">Información de las Polizas de seguro del cliente</td>
        <td colspan="4" align="left" class="style10">Información de cronograma por poliza- Seleccione un N° Póliza</td>
    </tr>
    
    <tr>
        <td colspan="4" align="center"><form name="form1" action=""><div id="grdPoliza"></div></form></td>
        <td colspan="4" align="center"><form name="form2" action=""><div id="grdCronograma"></div></form></td>
    </tr>
    <tr>
         <td colspan="8" align="center" class="style10"><hr/></td>
    </tr>
       
    <tr>
        <td colspan="4" align="left" class="style10">Información de Siniestros</td>
        <td colspan="4" align="left" class="style10">Información de visitas</td>
    </tr>
            
    <tr>
        <td colspan="4" align="center"><form name="form3" action=""><div id="grdSiniestro"></div></form></td>
        <td colspan="4" align="center"><form name="form4" action=""><div id="grdVisita"></div></form></td>
    </tr>

    <tr>
         <td colspan="8" align="center" class="style10"><hr/></td>
    </tr>
    


   </table>

    <script type="text/javascript">
        $(document).ready(function () {



            var txtCliente = $("#txtCliente").kendoAutoComplete({
                dataTextField: "dCliente",
                filter: "startswith",
                minLength: 3,
                dataSource: {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/CotizacionSeguro.svc/listarClientes",
                            data: {
                                Accept: "application/json"
                            }
                        },
                        change: function () {
                            var viewModel = Kendo.observable({
                                inst: this.view()[0]
                            });
                            kendo.bind($("#txtcliente"), viewModel.inst);
                        }
                    }
                }
            }).data("kendoAutoComplete");

            var _txtCliente = "0";

            $("#btnBuscar").click(
            function () {


                if (txtCliente.value() != "") _txtCliente = txtCliente.value().split("-")[1];
                cargaPoliza();
                cargaCronogramaPoliza();
                cargarSiniestros();
                cargarVisita();
            });


            function cargarSiniestros() {

                var grdSiniestroData;

                grdSiniestroData = new kendo.data.DataSource(
                {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/PolizaSeguro.svc/listarClientePolizaSiniestro/" + _txtCliente,
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    pageSize: 10
                });

                $("#grdSiniestro").kendoGrid({
                    dataSource: grdSiniestroData,
                    groupable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true
                    },
                    selectable: "multiple",
                    dataBound: function () {
                        var grid = this;
                        grid.table.find("tr").find("td:first input")
                        .change(function (e) {
                            var checkbox = $(this);
                            var selected = grid.table.find("tr").find("td:first input:checked").closest("tr");
                            grid.clearSelection();
                            if (selected.length) {
                                grid.select(selected);
                            }
                        });
                    },
                    columns: [
                        { width: 70, field: "nSiniestro", title: "Num. Siniestro" },
                        { width: 70, field: "nSiniestroCia", title: "Num. Siniestro Cia" },
                        { width: 70, field: "dCausa", title: "Causa" },
                        { width: 100, field: "dAjustador", title: "Ajustador" },
                        { width: 70, field: "fDenuncia", title: "Denuncia" },
                        { width: 90, field: "nPresupuesto", title: "Presupuesto" },
                        { width: 90, field: "nAproximado", title: "Pago Estimado" },
                        { width: 90, field: "nPagado", title: "Pagado" },
                    ]
                });
            }

            function cargaPoliza() {

                var grdPolizaData;

                grdPolizaData = new kendo.data.DataSource(
                {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/PolizaSeguro.svc/listarClientePoliza/" + _txtCliente,
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    pageSize: 10
                });

                $("#grdPoliza").kendoGrid({
                    change: onChange_Grid,
                    dataSource: grdPolizaData,
                    groupable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true
                    },
                    selectable: "multiple",
                    dataBound: function () {
                        var grid = this;
                        grid.table.find("tr").find("td:first input")
                        .change(function (e) {
                            var checkbox = $(this);
                            var selected = grid.table.find("tr").find("td:first input:checked").closest("tr");
                            grid.clearSelection();
                            if (selected.length) {
                                grid.select(selected);
                            }
                        });
                    },
                    columns: [
                        { width: 16, template: '<input id="${cPoliza}" type="checkbox" />', filterable: false, sortable: false },
                        { width: 30, field: "nroPoliza", title: "N° Poliza" },
                        { width: 40, field: "cPolizaSBS", title: "N° Poliza Cia" },
                        { width: 40, field: "dAseguradora", title: "Aseguradora" },
                        { width: 40, field: "fEmision", title: "F.Emisión" },
                        { width: 40, field: "fInicioVigencia", title: "F. Ini. Vigencia" },
                        { width: 40, field: "fFinVigencia", title: "F. Fin Vigencia" },
                        { width: 20, field: "nPrimaNeta", title: "Prima" },
                        { width: 30, field: "dEstadoPoliza", title: "Estado" },
                    ]
                });



            }

            function onChange_Grid() {
                cargaCronogramaPoliza();
            }


            function cargaCronogramaPoliza() {

                var haySel = false;
                var strPoliza = '0';
                for (var i = 0; i < document.forms["form1"].elements.length; i++) {
                    var elemento = document.forms[0].elements[i];
                    if (elemento.type == "checkbox" && elemento.checked) {
                        haySel = true;
                        strPoliza = elemento.id;
                    }
                }


                var grdCronogramaData;

                grdCronogramaData = new kendo.data.DataSource(
                {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/PolizaSeguro.svc/listarClientePolizaCronograma/" + _txtCliente + "/" + strPoliza,
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    pageSize: 10
                });

                $("#grdCronograma").kendoGrid({
                    dataSource: grdCronogramaData,
                    groupable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true
                    },
                    selectable: "multiple",
                    dataBound: function () {
                        var grid = this;
                        grid.table.find("tr").find("td:first input")
                        .change(function (e) {
                            var checkbox = $(this);
                            var selected = grid.table.find("tr").find("td:first input:checked").closest("tr");
                            grid.clearSelection();
                            if (selected.length) {
                                grid.select(selected);
                            }
                        });
                    },
                    columns: [
                        { width: 30, field: "fvencimiento", title: "F.Vencimiento" },
                        { width: 10, field: "nCuota", title: "N°" },
                        { width: 20, field: "nCuotaInicial", title: "Cuota Inicial" },
                        { width: 20, field: "nimpcuota", title: "Cuota" },
                        { width: 30, field: "dEstadoPago", title: "Estado" },
                        { width: 30, field: "fPago", title: "F. Pago" },
                    ]
                });


            }

            function cargarVisita() {

                var grdVisitaData;

                grdVisitaData = new kendo.data.DataSource(
                {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/PolizaSeguro.svc/listarClientePolizaVisita/" + _txtCliente,
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    pageSize: 10
                });

                $("#grdVisita").kendoGrid({
                    dataSource: grdVisitaData,
                    groupable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true
                    },
                    selectable: "multiple",
                    dataBound: function () {
                        var grid = this;
                        grid.table.find("tr").find("td:first input")
                        .change(function (e) {
                            var checkbox = $(this);
                            var selected = grid.table.find("tr").find("td:first input:checked").closest("tr");
                            grid.clearSelection();
                            if (selected.length) {
                                grid.select(selected);
                            }
                        });
                    },
                    columns: [
                        { width: 10, field: "cVisita", title: "N° Visita" },
                        { width: 50, field: "dEjecutivo", title: "Ejecutivo" },
                        { width: 40, field: "fAtencion", title: "F. Atención" },
                        { width: 30, field: "dEstadoVisita", title: "Estado" },
                        { width: 30, field: "dResultado", title: "Resultado" },
                    ]
                });
            }


            $("#btnSalir").click(function () {
                document.location.href = "../../Default.aspx";
            });
            // FIN DOCUMENTO
        });    

        
        
    </script>

    </div>
</body>
</html>


